<?php
$caption = BUtils::T('lunch_special_lbl');
$this->pageTitle = Yii::app()->name . ' - ' . $caption;

$create_special_btn = BUtils::T('lunch_special_create_btn');
$all_lbl = BUtils::T('all_op_lbl');
$last_page = Yii::app()->createUrl('/lunch');
?>
<div class="container prepend-top">
	<?php echo CHtml::button('< ' . BUtils::T('back_btn'), array('class'=>'button', 'onclick'=>"location.href='{$last_page}'")); ?>
</div>

<div class="container prepend-top append-bottom">
	
	<div class="span-17">
		<div class="box_white">
			<div class="biz-form">
				<div class="margin">
					<div class="left"><h3><?php echo $caption; ?></h3></div>
					<div class="right">
						<?php echo CHtml::link("<span>{$create_special_btn}</span>", Yii::app()->createUrl('/special/form', array('view'=>'lunch')), array('class'=>'button button-huge button-compliment', 'id'=>'create_new_special')) ?>
					</div>
					<div class="clear"></div>
					<div class="tips"><?php echo BUtils::T('special_offer_list_eg'); ?></div>
				</div>
				
				<div class="fieldswrap">
					<div class="fields mobile" style="text-align:right;">
<?php
echo CHtml::form(Yii::app()->createUrl($this->id.'/'.$this->action->id), 'post');
echo CHtml::dropDownList('filter_week', '', BUtils::WeekDayKeys(5), array('empty'=>$all_lbl)) . '<span class="space-1"></span>';
echo CHtml::dropDownList('filter_status', '', BUtils::SpecialStatus(), array('empty'=>$all_lbl)) . '<span class="space-1"></span>';
echo CHtml::dropDownList('filter_date', '', BUtils::SpecialValidStatus(), array('empty'=>$all_lbl)) . '<span class="space-1"></span>';
echo CHtml::ajaxSubmitButton(BUtils::T('search_btn'), null, array('beforeSend'=>'beforeSend', 'success'=>'success'), array('class'=>'button button-huge button-confirm'));
echo CHtml::endForm();
?>
					</div>
					<div class="mobile">
						<div id="loading-bar" style="text-align:center; margin:20px 0;">
							<img src="<?php echo Yii::app()->baseUrl; ?>/images/loader-bar.gif" />
						</div>
<table class="va-top" id="special-list">
</table>
<!-- end of <table class="va-top"> -->
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="span-7 right last">
		<div class="box_white redemption_space">
			<div class="biz-form margin" id="redeembox" style="background:#fec">
				<h3><?php echo BUtils::T('special_redeem_btn'); ?></h3>
				<div class="tips"><?php echo BUtils::T('special_redeem_btn_eg'); ?></div>
				<div class="redemption_box">
<?php
echo CHtml::form('redeem-form', 'post');
echo CHtml::textField('code', '', array('class'=>'auto code'));
echo '<div class="reply" id="redeem-reply"></div>';
echo CHtml::ajaxSubmitButton(BUtils::T('special_redeem_btn'), Yii::app()->createUrl('/special/redeem'), array('beforeSend'=>'beforeRedeem', 'success'=>'afterRedeem'), array('class'=>'button button-huge button-confirm button-thin'));
echo CHtml::endForm();
?>
				</div>
			</div>
		</div>
		<div class="box_white prepend-top append-bottom">
			<div class="biz-form margin">
				<h3><?php echo BUtils::T('how_does_it_work_lbl'); ?></h3>
				<div class="tips"><?php echo BUtils::T('how_special_works_eg'); ?></div>
				<ol class="line">
					<li><?php echo BUtils::T('how_special_works_t1'); ?></li>
					<li><?php echo BUtils::T('how_special_works_t2'); ?></li>
					<li><?php echo BUtils::T('how_special_works_t3'); ?></li>
					<li><?php echo BUtils::T('how_special_works_t4'); ?></li>
				</ol>
				<hr />
				<div class="span-1"><img src="<?php echo Yii::app()->baseUrl; ?>/images/special-star-red.png" width="32" alg="<?php echo BUtils::T('current_lbl'); ?>" /></div>
				<div style="padding-top:7px;"><?php echo BUtils::T('current_specials_lbl'); ?></div>
				<div class="clear"></div>
				<div class="span-1"><img src="<?php echo Yii::app()->baseUrl; ?>/images/special-star-pink.png" width="32" alg="<?php echo BUtils::T('upcoming_lbl'); ?>" /></div>
				<div style="padding-top:7px;"><?php echo BUtils::T('upcoming_specials_lbl'); ?></div>
				<div class="clear"></div>
				<div class="span-1"><img src="<?php echo Yii::app()->baseUrl; ?>/images/special-star-gray.png" width="32" alg="<?php echo BUtils::T('expired_lbl'); ?>" /></div>
				<div style="padding-top:7px;"><?php echo BUtils::T('expired_specials_lbl'); ?></div>
				<div class="clear"></div>
			</div>
		</div>
	</div>
	
</div>
<script type="text/javascript">
$(function() {
	jQuery.ajax({
		'type':'POST',
		'url':location.href,
		'cache':false,
		'data':jQuery(this).parents("form").serialize(),
		'beforeSend':beforeSend,
		'success':success
	});
});
function beforeSend() {
	$("#loading-bar").show();
	$("#special-list").html('');
}
function success(html) {
	$("#loading-bar").hide();
	$("#special-list").html(html);
}
function beforeRedeem() {
	$("#redeem-reply").html('<img src="<?php echo Yii::app()->baseUrl; ?>/images/loader-bar.gif" />');
}
function afterRedeem(html) {
	$("#redeem-reply").html(html);
}
</script>